import { creatElementData } from "./parseTsFile";
import fs from "fs";
import path from "path";
import axios from "axios";
export interface DataProps {
  name: string;
  description: string;
  filePath: string;
}
const data = [
  {
    name: "Time",
    description: "Time相关函数(相关函数都会挂在到windows.$time中)",
    filePath: "time",
  },
  {
    name: "Reg",
    description: "正则表达式验证规则(相关函数都会挂在到windows.$reg中)",
    filePath: "reg",
  },
  {
    name: "Url",
    description: "浏览器网址(相关函数都会挂在到windows.$url中)",
    filePath: "Url",
  },
];
creatElementData(data).then((res) => {
  const postUrl =
    "https://tcb-mnnvd2dylbogjrre641c9-e382db.service.tcloudbase.com/BlogCommonDomJson";
  axios.post(postUrl, { setJson: true, data: res }).then((res) => {
    console.log(res.data, "提交之后");
  });
  fs.writeFile(
    path.resolve(__dirname, `./data.json`),
    JSON.stringify(res),
    (err) => {
      if (err) throw err;
      console.log("新JSON创建成功");
    }
  );
});
